#define BOOST_TEST_MODULE testElementRoleMenuItem

#include <boost/test/unit_test.hpp>

#include "common/elements/element_maker.h"
#include "common/elements/role_menu_item.h"

BOOST_AUTO_TEST_CASE(testRoleMenuItemJson)
{
    auto first = std::make_shared<Elements::RoleMenuItem>();
    first->setId(1);
    first->setRoleId(2);
    first->setCaption("a");
    first->setLink("b");
    first->setIcon("c");

    const auto json = first->toJsonString();
    const Elements::ElementPtr second(Elements::fromJsonString(json));
    BOOST_CHECK(first->isSame(second.get()));

    const auto third = std::static_pointer_cast<Elements::RoleMenuItem>(second);
    BOOST_CHECK(1 == third->id());
    BOOST_CHECK(2 == third->roleId());
    BOOST_CHECK("a" == third->caption());
    BOOST_CHECK("b" == third->link());
    BOOST_CHECK("c" == third->icon());
}
